import { BaseConnection } from "tsrpc";
import component, { ComType } from "../core/tool/component";
import common from "../core/tool/common";
import { analysisIntent } from "../core/tool/baseScene";
import { mathType } from "../core/tool/face";
import { Icard } from "../core/tool/Icard";
import bag_component from "./bag_component";
import gameCfg from "../gameCfg";
import base_component from "./base_component";
import rpg_component from "./rpg_component";
import { IBodyCreateConfig } from "../core/rpg/types";
import { CreateService } from "../service/CreateService";

/**
 * 创建组件 - 主要负责UI交互和状态管理
 * 职责：
 * 1. 管理实体创建数据
 * 2. 提供创建数据访问接口
 * 3. 处理数据格式化
 */
export default class create_component extends component {
    constructor() {
        super();
    }
    
    /**
     * 获取创建数据
     * @returns 创建配置数据
     */
    get_create_data():IBodyCreateConfig {
        const baseComponent = this.getComponent(ComType.base) as base_component;
        const rpgComponent = this.getComponent(ComType.rpg) as rpg_component;
        
        return CreateService.getCreateData(baseComponent, rpgComponent);
    }

    /**
     * 验证当前创建数据
     * @returns 验证结果
     */
    validateCreateData(): {
        isValid: boolean;
        errors: string[];
    } {
        const createData = this.get_create_data();
        return CreateService.validateCreateData(createData);
    }

    /**
     * 获取格式化的创建数据用于显示
     * @returns 格式化后的显示数据
     */
    getFormattedCreateData(): {
        displayName: string;
        basicInfo: string;
        skillInfo: string;
    } {
        const createData = this.get_create_data();
        return CreateService.formatCreateDataForDisplay(createData);
    }

    /**
     * 获取创建数据摘要
     * @returns 数据摘要
     */
    getCreateDataSummary(): {
        name: string;
        level: number;
        skillCount: number;
        hasUrl: boolean;
        hasEmoji: boolean;
    } {
        const createData = this.get_create_data();
        return CreateService.getCreateDataSummary(createData);
    }
}

